//
// Created by Administrator on 2025/3/25.
//

#ifndef MYTEST_02_SC_CTOR_H
#define MYTEST_02_SC_CTOR_H



// Learn with Examples, 2020, MIT license
#include <systemc>
using namespace sc_core;

SC_MODULE(MODULE_02_A) {
    SC_CTOR(MODULE_02_A) { // constructor taking only module name
        SC_METHOD(func_a); // register member function to systemC simulation kernel, to be explained later.
    }
    void func_a() { // a member function with no input, no output
        std::cout << "name()" << std::endl;
        std::cout << this->name() << std::endl;
    }
};

SC_MODULE(MODULE_02_B) {
    SC_CTOR(MODULE_02_B) { // constructor
        SC_METHOD(func_b); // register member function
    }
    void func_b(); // declare function
};

void MODULE_02_B::func_b() { // define function outside class definition
    std::cout << this->name() << std::endl;
}

SC_MODULE(MODULE_02_C) { // constructor taking more arguments
    const int i;
    SC_CTOR(MODULE_02_C); // SC_HAS_PROCESS is recommended, see next example for details
    MODULE_02_C(sc_module_name name, int i) : sc_module(name), i(i) { // explcit constructor
        SC_METHOD(func_c);
    }
    void func_c() {
        std::cout << this->name() << ", i = " << i << std::endl;
    }
};

class testbench_02{
public:
    testbench_02(){
        MODULE_02_A a("MODULE_02_A");
        MODULE_02_B b("MODULE_02_B");
        MODULE_02_C c("MODULE_02_C",1);

    }

};




#endif //MYTEST_02_SC_CTOR_H
